<!DOCTYPE html>
<html>

    <head>
        <meta name="viewport" content="width=device-width,initial-scale=1,minimum-scale=1,maximum-scale=1" />
        <meta charset="UTF-8">
        <title>{$site_info.site_name|default=''}</title>
        <meta name="keywords" content="{$site_info.site_seo_keywords|default=''}"/>
        <meta name="description" content="{$site_info.site_seo_description|default=''}">
        <include file="public@head"/>
    </head>
    <body>
		
		<div class="repaDetail repairs">
			<!--头部-->
			<div class="top" style="background: url({:cmf_get_image_url($img['img'])}) no-repeat;background-size: 100% 100%;">
				<p>我的派单</p>
			</div>
			
			<div class="reDetail">
				<div class="reDeSub">
					<div class="reTil">
						<img src="__TMPL__/public/assets/images/g4.png" />
						<p>{$repair_info.post_title}</p>
						<p class="state blueT">{$repair_info.repair_status_text}</p>
					</div>
					<div class="reDeCn">
						<div class="deList">
							<label>报修类型：</label>
							<p>{$repair_info.category_name}</p>
						</div>
						<div class="deList">
							<label>相关部门：</label>
							<p>{$repair_info.member_info.department}</p>
						</div>
						<div class="deList">
							<label>联&nbsp;&nbsp;系&nbsp;&nbsp;人：</label>
							<p>{$repair_info.member_info.user_login}</p>
						</div>
						<div class="deList">
							<label>电&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;话：</label>
							<p>{$repair_info.member_info.mobile}</p>
						</div>
						<div class="deList">
							<label>地&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;点：</label>
							<p>{$repair_info.repair_place}</p>
						</div>
						<div class="deList">
							<label>故障内容：</label>
							<p>{$repair_info.post_content}</p>
						</div>
						<div class="deList deAllImg">
							<foreach name="repair_info.img.photos" item="vo" key="k">
							<label><if condition="$k eq 0">故障图片：<else/>&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;</if></label>
							<div class="deLImg">
								<img src="{:cmf_get_image_url($vo.url)}" />
							</div>
							</foreach>
						</div>

						<if condition="$repair_info.repairman_info">
						<div class="oDeList div_float">
							<div class="l">
								<label>维修人员：</label>
								<p>{$repair_info.repairman_info.user_login}</p>
							</div>
							<div class="r">
								<label>手&nbsp;&nbsp;机：</label>
								<p>{$repair_info.repairman_info.mobile}</p>
							</div>
						</div>
						</if>

						<!-- 如果是已维修完成并且没有评价的维修单 -->
						<if condition="$repair_info.repair_status eq 3 and $repair_info.evaluate_status eq 0 and $user_type neq 'fix'">
						<div class="deList div_float">
							<label>评&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;价：</label>
							<div class="leave div_float">
								<div class="btml">
									<div class="evRadio radioSel">
										<input type="radio" checked="checked" name="evaluate_status" value="1" onclick="changeSel($(this))" />
									</div>
									<label>满意</label>
								</div>
								<div class="btml">
									<div class="evRadio">
										<input type="radio" name="evaluate_status" value="2" onclick="changeSel($(this))" />
									</div>
									<label>基本满意</label>
								</div>
								<div class="btml">
									<div class="evRadio">
										<input type="radio"  name="evaluate_status" value="3" onclick="changeSel($(this))"  />
									</div>
									<label>不满意</label>
								</div>
							</div>
						</div>
						<button class="submitBtn" onclick="evaluatePost()">立即提交</button>
						</if>

						<!-- 如果是维修人员 -->
						<if condition="$user_type eq 'fix' and $repair_info.repair_status neq 4 and $repair_info.repair_status neq 3">
						<button class="submitBtn" onclick="javascript:location.href='/repair/list/add_repair/id/{$repair_info.id}'">维修完成</button>
						</if>

					</div>
				</div>
			</div>
			
			
			<!--公共底部-->
			<include file='public@footer'/>

		</div>
		
	
	<include file='public@scripts'/>
	<script>
		//改变选择的radio 
		function changeSel(pOne){
			pOne.parents('.evRadio').addClass('radioSel');
			pOne.parents('.leave').find('input').attr('checked',false);
			pOne.attr('checked',true);
			pOne.parents('.btml').siblings().find('.evRadio').removeClass('radioSel');
		}

		//异步提交评价
		function evaluatePost(){
			var evaluate_status = $("input[name='evaluate_status']:checked").val();
			if (evaluate_status<1) {
				alert('请选择您的满意程度');
			}else{

				$.ajax({ 
					url: "{:url('ajaxEvaluate')}", 
					type:"POST",
					data: {
						repair_id:"{$repair_info.id}",
						evaluate_status:evaluate_status
					},
					dataType:"json",
					success: function(data){
			    		if (data.error == 0) {
			    			alert(data.msg);
			    			window.location.href=data.url;
			    		}
			   		} ,
			   		error:function(){
			   			alert(data.msg);
			   			console.log("失败");
			   		}
			   	});
			}
		}
	</script>
	</body>
</html>
